import pickle
import json


class Student:
    # 构造函数
    def __init__(self, name, age):
        self.__name = name#私有属性
        self.age = age

    def info(self):
        print("my name is %s, i am %s"%(self.__name, self.age))


stu1 = Student("liurong", 27)
stu1.info()

file = open("stu1.pickle", "wb")
pickle.dump(stu1, file)
file.close()

file = open('stu1.pickle', 'rb')
stu2 = pickle.load(file)
stu2.age=30
stu2.info()
file.close()
